package client;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

public class ClientTcpSend {

    public static void main(String[] args) throws IOException {
        int length = 0;
        byte[] sendByte = null;
        Socket socket = null;
        DataOutputStream dout = null;
        FileInputStream fin = null;

        socket = new Socket();
        socket.connect(new InetSocketAddress("127.0.0.1", 33456),10 * 1000);
        dout = new DataOutputStream(socket.getOutputStream());
        File file = new File("E:\\TU\\DSCF0320.JPG");
        fin = new FileInputStream(file);
        sendByte = new byte[1024];
        dout.writeUTF(file.getName());
        while((length = fin.read(sendByte, 0, sendByte.length))>0){
            dout.write(sendByte,0,length);
            dout.flush();
        }


    }

}